check string in php

59

how to check if a string contains a substring in php -

$a = 'How are you?';

if (strpos($a, 'are') !== false) {
    echo 'true';
}

check string php -

is_string(mixed $value): bool

php check if string contains a char -

$haystack = 'This is my haystack that we shall check'
$has_A = strpos($haystack, 'A') !== false;
$has_a = strpos($haystack, 'a') !== false;

Comments

Submit
0 Comments